package com.woniuxy.lab.woniu_lab_boss.components;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.woniu.mgr.common.Result;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.authentication.AuthenticationFailureHandler;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//
//@Component
//@Slf4j
//public class LoginErrorHandler implements AuthenticationFailureHandler {
//
//	@Resource
//	private ObjectMapper objectMapper;
//
//
//	@Override
//	public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
//		log.warn("登陆失败",e);
//		Result result = Result.fail(500,"登录失败");
//		result.setCode(500);
//		result.setMessage("登录失败");
//		String resultJson = objectMapper.writeValueAsString(result);
//
//		httpServletResponse.setCharacterEncoding("utf8");
//		httpServletResponse.setContentType("application/json;charset=utf8");
//
//		PrintWriter writer = httpServletResponse.getWriter();
//		writer.write(resultJson);
//		writer.flush();
//	}
//}
